package com.hundsun.yr.universal.p2p.ui.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.hundsun.mobile.zwgt.R;
import com.hundsun.yr.universal.library.Utils.HeaderMap;
import com.hundsun.yr.universal.library.base.BaseAppManager;
import com.hundsun.yr.universal.library.base.BaseWebActivity;
import com.hundsun.yr.universal.library.common.PackageUtils;
import com.hundsun.yr.universal.library.data.HSSharedPreferences;
import com.hundsun.yr.universal.library.eventbus.EventCenter;
import com.hundsun.yr.universal.library.netstatus.NetUtils;
import com.hundsun.yr.universal.library.widget.HSToast;
import com.hundsun.yr.universal.p2p.bean.BankAccountBeen;
import com.hundsun.yr.universal.p2p.bean.UserInfo;
import com.hundsun.yr.universal.p2p.config.Config;
import com.hundsun.yr.universal.p2p.config.Constants;
import com.hundsun.yr.universal.p2p.config.Extras;
import com.hundsun.yr.universal.p2p.config.TaskConstants;
import com.hundsun.yr.universal.p2p.presenter.base.RequestPresenter;
import com.hundsun.yr.universal.p2p.presenter.impl.InitializePresenterImpl;
import com.hundsun.yr.universal.p2p.ui.activity.base.BaseMineWebActivity;
import com.hundsun.yr.universal.p2p.utils.BaseRequestTool2;
import com.hundsun.yr.universal.p2p.utils.CommTool;
import com.hundsun.yr.universal.p2p.utils.KeyBoardListener;
import com.hundsun.yr.universal.p2p.utils.Logs;
import com.hundsun.yr.universal.p2p.view.base.InitializeView;

import org.json.JSONObject;

import java.util.HashMap;

import de.greenrobot.event.EventBus;

public class WebOpenAccountActivity extends BaseMineWebActivity implements InitializeView {

    public HSSharedPreferences sharedPreferences = null;
    /**
     * 支持放大缩小
     */
    public static final String supportZoom = "supportZoom";
    private boolean supportZoomFlag;

    private boolean flag;

    /**
     * 目标跳转地址
     */
    private String flagUrl = "";

    /**
     * 请求时间
     */
    private String zwgt_data;

    /**
     * 请求接口
     **/
    private RequestPresenter mPresenter = null;
    private BankAccountBeen bankAccountBeen;

    @Override
    protected boolean isApplyStatusBarTranslucency() {
        // TODO Auto-generated method stub
        return true;
    }

    @Override
    protected View getLoadingTargetView() {

        if (mBrowserLayout == null) {
        }
        return mBrowserLayout;
    }


    @Override
    protected void onNetworkConnected(NetUtils.NetType type) {
        mBrowserLayout.refresh();
        toggleHide();
    }

    @Override
    protected void getBundleExtras(Bundle extras) {
        super.getBundleExtras(extras);
        supportZoomFlag = extras.getBoolean(supportZoom);
    }

    @Override
    protected void onNetworkDisConnected() {

        toggleNetworkError(true, new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                if (NetUtils.isNetworkConnected(getBaseContext())) {
                    showToast("请检查网络...");
                } else {
                    mBrowserLayout.refresh();
                    toggleHide();
                }
            }
        });

    }


    @Override
    protected void initViewsAndEvents() {
        super.initViewsAndEvents();
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
        KeyBoardListener.getInstance(this).init();

        mPresenter = new InitializePresenterImpl(mContext, this);

        mToolBar.setNavigationOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                webBack();
            }
        });

        sharedPreferences = new HSSharedPreferences(mContext, Config.SPPath.file_userLoginedInfo);
        setCookie();
        toolbar_title.setText(mWebTitle);
//        mToolBar.setNavigationOnClickListener(this);

        mBrowserLayout.mWebView.setWebViewClient(new WebViewClient() {
/*
            @Override
            public WebResourceResponse shouldInterceptRequest(WebView view, final WebResourceRequest request) {
                final String method = request.getMethod();
                String url = request.getUrl().toString();
                Logs.e("xushunzhen: shouldInterceptRequest: " + request.getUrl().toString() + ",method: " + method);

                if (method.equals("POST") && (url.contains(getString(R.string.h5_user) + TaskConstants.TASK_ACTRST) || url.contains(getString(R.string.h5_user) + TaskConstants.TASK_RECHARGERST) || url.contains(getString(R.string.h5_user) + TaskConstants.TASK_REPAYAUTHPAGERST) || url.contains(getString(R.string.h5_user) + TaskConstants.TASK_PAYMENTAUTHPAGERST))) {
                    Logs.e("xushunzhen: method: " + method);
                    flag = true;
                    flagUrl = url;
                }

                return super.shouldInterceptRequest(view, request);
            }

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, final WebResourceRequest request) {

                String url = request.getUrl().toString();
                String method = request.getMethod();

                Logs.e("xushunzhen: shouldOverrideUrLoading: " + request.getUrl().toString() + ",heade: " + mHeader.toString() + ",method: " + method);

                if (url.contains("zwgt.com")) {
                    syncCookie(mContext, url, sharedPreferences.getShareProf(UserInfo.USER_NO), sharedPreferences.getShareProf(UserInfo.TOKENID), PackageUtils.getVersionName(mContext));
                }

                if (url.contains("timeout.html") && flag) {
                    Logs.e("xushunzhenflagUrl: " + flagUrl + ",header: " + mHeader.toString());

                    syncCookie(mContext, flagUrl, sharedPreferences.getShareProf(UserInfo.USER_NO), sharedPreferences.getShareProf(UserInfo.TOKENID), PackageUtils.getVersionName(mContext));
                    mBrowserLayout2.loadUrl(flagUrl, mHeader);
                    mBrowserLayout2.setVisibility(View.VISIBLE);
                    mBrowserLayout.setVisibility(View.GONE);

                    WebChromeClient wvcc = new WebChromeClient() {
                        @Override
                        public void onReceivedTitle(WebView view, String title) {
                            super.onReceivedTitle(view, title);
//                Logs.e("ReceivedTitle: " + title);
                            toolbar_title.setMaxLines(1);
                            toolbar_title.setMaxEms(7);
                            toolbar_title.setEllipsize(TextUtils.TruncateAt.END);
                            if (title != null && !title.isEmpty()) {
                                toolbar_title.setText(title);
                            }
                        }
                    };
                    mBrowserLayout2.getWebView().setWebChromeClient(wvcc);

                    mBrowserLayout2.getWebView().getSettings().setJavaScriptEnabled(true);
                    mBrowserLayout2.getWebView().addJavascriptInterface(WebOpenAccountActivity.this, "wjj");

                    flag = false;
                } else {
                    Logs.e("xushunzhen:else: " + url);
                    mBrowserLayout.loadUrl(url, mHeader);
                }

                return true;
            }*/

            @Override
            public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
                Log.e("testUrl3", url);
                if (url.contains(getString(R.string.h5_user) + TaskConstants.TASK_ACTRST) ||
                        url.contains(getString(R.string.h5_user) + TaskConstants.TASK_RECHARGERST) ||
                        url.contains(getString(R.string.h5_user) + TaskConstants.TASK_REPAYAUTHPAGERST) ||
                        url.contains(getString(R.string.h5_user) + TaskConstants.TASK_PAYMENTAUTHPAGERST) ||
                        url.contains(getString(R.string.h5_user) + "withdrawrst") ||
                        url.contains(getString(R.string.h5_user) + "bindcardpagerst") ||
                        url.contains(getString(R.string.h5_user) + "untie") ||
                        url.contains(getString(R.string.h5_user) + "investsucess") ||
                        url.contains(getString(R.string.h5_user) + "rebankpwd") ||
                        url.contains(getString(R.string.h5_user) + "setbankpwd") ||
                        url.contains(getString(R.string.h5_user) + "repayauthcancel") ||
                        url.contains(getString(R.string.h5_user) + "paymentauthcancel")
                ) {
                    flag = true;
                    flagUrl = url;
                    Log.e("flagUrl", flagUrl);
                }
                return super.shouldInterceptRequest(view, url);
            }


            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {

                Logs.e("xushunzhen: shouldOverrideUrLoading: " + url + ",heade: " + mHeader.toString());

                if (url.contains("zwgt.com")) {
                    syncCookie(mContext, url, sharedPreferences.getShareProf(UserInfo.USER_NO), sharedPreferences.getShareProf(UserInfo.TOKENID), PackageUtils.getVersionName(mContext));
                }

                if (url.contains("timeout.html") && flag) {
                    Logs.e("xushunzhenflagUrl: " + flagUrl + ",header: " + mHeader.toString());

                    syncCookie(mContext, flagUrl, sharedPreferences.getShareProf(UserInfo.USER_NO), sharedPreferences.getShareProf(UserInfo.TOKENID), PackageUtils.getVersionName(mContext));
                    mBrowserLayout2.loadUrl(flagUrl, mHeader);
                    mBrowserLayout2.setVisibility(View.VISIBLE);
                    mBrowserLayout.setVisibility(View.GONE);

                    WebChromeClient wvcc = new WebChromeClient() {
                        @Override
                        public void onReceivedTitle(WebView view, String title) {
                            super.onReceivedTitle(view, title);
//                Logs.e("ReceivedTitle: " + title);
                            toolbar_title.setMaxLines(1);
                            toolbar_title.setMaxEms(7);
                            toolbar_title.setEllipsize(TextUtils.TruncateAt.END);
                            if (title != null && !title.isEmpty()) {
                                toolbar_title.setText(title);
                            }
                        }
                    };
                    mBrowserLayout2.getWebView().setWebChromeClient(wvcc);

                    mBrowserLayout2.getWebView().getSettings().setJavaScriptEnabled(true);
                    mBrowserLayout2.getWebView().addJavascriptInterface(WebOpenAccountActivity.this, "wjj");

                    flag = false;
                } else {
                    Logs.e("xushunzhen:else: " + url);
                    mBrowserLayout.loadUrl(url, mHeader);
                }

                return true;
            }
        });

        WebChromeClient wvcc = new WebChromeClient() {
            @Override
            public void onReceivedTitle(WebView view, String title) {
                super.onReceivedTitle(view, title);
//                Logs.e("ReceivedTitle: " + title);
                toolbar_title.setMaxLines(1);
                toolbar_title.setMaxEms(7);
                toolbar_title.setEllipsize(TextUtils.TruncateAt.END);
                if (title != null && !title.isEmpty()) {
                    toolbar_title.setText(title);
                }
            }
        };
        mBrowserLayout.getWebView().setWebChromeClient(wvcc);

        mBrowserLayout.getWebView().getSettings().setJavaScriptEnabled(true);
        mBrowserLayout.getWebView().addJavascriptInterface(WebOpenAccountActivity.this, "wjj");

        if (supportZoomFlag) {
            mBrowserLayout.mWebView.getSettings().setSupportZoom(supportZoomFlag);
            mBrowserLayout.mWebView.getSettings().setBuiltInZoomControls(supportZoomFlag);
        }

    }

    @Override
    protected boolean isApplyKitKatTranslucency() {
        // TODO Auto-generated method stub
        return false;
    }

    protected void initImmersionBar() {
        super.initImmersionBar();
        mImmersionBar.titleBar(R.id.common_toolbar).init();
    }

    /**
     * 查看红包
     */
    @JavascriptInterface
    public void redBag() {
        zwgt_data = BaseRequestTool2.getFormatedDateString();
        HashMap<String, String> hearder = BaseRequestTool2.getHearder(mContext, TaskConstants.TASK_GET, mContext.getString(R.string.h5_user) +
                TaskConstants.TASK_MYDISCOUNT, sharedPreferences.getShareProf(UserInfo.USER_NO), sharedPreferences.getShareProf(UserInfo.TOKENID), zwgt_data);
        HeaderMap headerMap = new HeaderMap();
        headerMap.setMap(hearder);
        Bundle bundle = new Bundle();
        bundle.putString(BaseWebActivity.BUNDLE_KEY_TITLE, getString(R.string.mine_bonus));
        bundle.putString(BaseWebActivity.BUNDLE_KEY_URL, getString(R.string.root_h5_url_test) + getString(R.string.h5_user) + TaskConstants.TASK_MYDISCOUNT);
        bundle.putSerializable(BaseWebActivity.BUNDLE_KEY_HEADER, headerMap);
        bundle.putInt(BaseWebActivity.BUNDLE_KEY_LOADTYPE, BaseWebActivity.LoadType.HTTP.getIntValue());
        bundle.putBoolean(BaseWebActivity.BUNDLE_KEY_SHOW_BOTTOM_BAR, false);
        readyGoThenKill(WebActivity.class, bundle);
    }

    /**
     * 继续了解项目
     */
    @JavascriptInterface
    public void investList() {
//        showToast("继续了解项目");
        EventBus.getDefault().post(new EventCenter(Extras.RECHARGE_SUCCESS_GO_TO_PROJECT));
        if (BaseAppManager.getInstance().getActivity(OpenAccountBankActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(OpenAccountBankActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(RepaymentAuthorizationActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(RepaymentAuthorizationActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(PayAuthorizationActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(PayAuthorizationActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(AuthorizationActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(AuthorizationActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(RechangeNewActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(RechangeNewActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(LendActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(LendActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(WithDrawActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(WithDrawActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(InvestDetailsActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(InvestDetailsActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(MineAssetsActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(MineAssetsActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(MineBankCardActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(MineBankCardActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(MineSettingActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(MineSettingActivity.class).finish();
        }
        Log.e("dddd", "name3");
        finish();
    }

    /**
     * 去授权列表页面
     */
    @JavascriptInterface
    public void toList() {
        if (BaseAppManager.getInstance().getActivity(RechangeNewActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(RechangeNewActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(RepaymentAuthorizationActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(RepaymentAuthorizationActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(PayAuthorizationActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(PayAuthorizationActivity.class).finish();
        }
        sharedPreferences.putShareProf(UserInfo.IF_PAYPWD, "YES");
        finish();
    }

    /**
     * 关闭页面
     */
    @JavascriptInterface
    public void finishActivity() {
        finish();
    }

    /**
     * 设置交易密码
     */
    @JavascriptInterface
    public void setTraderPassword() {
        zwgt_data = BaseRequestTool2.getFormatedDateString();
        JSONObject map = new JSONObject();

//        try {
//            map.put("vcode", "");
//        } catch (JSONException e) {
//            e.printStackTrace();
//        }

        JSONObject jsonParams = CommTool.getJSONParams(map, sharedPreferences.getShareProf(UserInfo.TOKENID).substring(0, 24), zwgt_data);
        mPresenter.loadingData(TaskConstants.TASK_SETBANKPWD, mContext.getString(R.string.root_url_test) + mContext.getString(R.string.api_user_test) + TaskConstants.TASK_SETBANKPWD, Constants.EVENT_DATA,
                jsonParams, BaseRequestTool2.getHearder(mContext, TaskConstants.TASK_POST, mContext.getString(R.string.api_user_test) + TaskConstants.TASK_SETBANKPWD, sharedPreferences
                        .getShareProf(UserInfo.USER_NO), sharedPreferences.getShareProf(UserInfo.TOKENID), zwgt_data), true);
    }

    /**
     * 同步结果
     */
    /*@JavascriptInterface
    public void refresh() {

    }*/
    @Override
    public <T> void initializeViews(String task_name, T data) {
        switch (task_name) {
            case TaskConstants.TASK_SETBANKPWD:
                if (data == null) {
                    return;
                }
                Log.e("rebankpwd", data.toString());
                zwgt_data = BaseRequestTool2.getFormatedDateString();
                HashMap<String, String> hearder = BaseRequestTool2.getHearder(mContext, TaskConstants.TASK_GET, mContext.getString(R.string.h5_user) +
                        "rebankpwd", sharedPreferences.getShareProf(UserInfo.USER_NO), sharedPreferences.getShareProf(UserInfo.TOKENID), zwgt_data);
                HeaderMap headerMap2 = new HeaderMap();
                headerMap2.setMap(hearder);
                Bundle bundler = new Bundle();
                bundler.putString(BaseWebActivity.BUNDLE_KEY_URL, data.toString());
                bundler.putSerializable(BaseWebActivity.BUNDLE_KEY_HEADER, headerMap2);
                bundler.putInt(BaseWebActivity.BUNDLE_KEY_LOADTYPE, BaseWebActivity.LoadType.DATA.getIntValue());
                readyGoThenKill(WebOpenAccountActivity.class, bundler);
                if (BaseAppManager.getInstance().getActivity(MineSettingActivity.class) != null) {
                    BaseAppManager.getInstance().getActivity(MineSettingActivity.class).finish();
                }
                break;
        }
    }

    @Override
    public <T> void initializeError(String task_name, T data) {

    }

    @Override
    public void finish() {
        super.finish();
        EventBus.getDefault().post(new EventCenter(Constants.EVENT_REFRESH_DATA));

        if (flagUrl != null && flagUrl.contains(getString(R.string.h5_user) + TaskConstants.TASK_ACTRST)) {
            EventBus.getDefault().post(new EventCenter(Extras.OPEN_ACCOUNT_SUCCESS));
        }
    }


    /**
     * 网页 返回
     */
    public void webBack() {
        if (BaseAppManager.getInstance().getActivity(OpenAccountBankActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(OpenAccountBankActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(RepaymentAuthorizationActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(RepaymentAuthorizationActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(PayAuthorizationActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(PayAuthorizationActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(AuthorizationActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(AuthorizationActivity.class).finish();
        }

        finish();
    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        // TODO Auto-generated method stub

        if (keyCode == KeyEvent.KEYCODE_BACK) {
            webBack();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    private void setCookie() {
        syncCookie(mContext, mWebUrl, sharedPreferences.getShareProf(UserInfo.USER_NO), sharedPreferences.getShareProf(UserInfo.TOKENID));
    }

    /**
     * 回到第一个加载的地方
     */
    @JavascriptInterface
    public void toLoan() {
        EventBus.getDefault().post(new EventCenter(Extras.RECHARGE_SUCCESS_GO_TO_LOAN));
        if (BaseAppManager.getInstance().getActivity(PayAuthorizationActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(PayAuthorizationActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(RepaymentAuthorizationActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(RepaymentAuthorizationActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(AuthorizationActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(AuthorizationActivity.class).finish();
        }
        finish();
    }

    /**
     * 绑卡页面回调
     */
    @JavascriptInterface
    public void toBindCard() {
        readyGo(MineBankCardActivity.class);
        finish();
    }

    /**
     * 绑卡页面
     */
    @JavascriptInterface
    public void rebindcard() {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                refresh();
            }
        });
    }
    /**
     *
     */
    /**
     * 项目列表
     */
    @JavascriptInterface
    public void toInvest() {
        EventBus.getDefault().post(new EventCenter(Extras.RECHARGE_SUCCESS_GO_TO_PROJECT));
        if (BaseAppManager.getInstance().getActivity(InvestDetailsActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(InvestDetailsActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(MineAssetsActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(MineAssetsActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(MineBankCardActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(MineBankCardActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(MineSettingActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(MineSettingActivity.class).finish();
        }


        if (BaseAppManager.getInstance().getActivity(LendActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(LendActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(WithDrawActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(WithDrawActivity.class).finish();
        }
        if (BaseAppManager.getInstance().getActivity(InvestActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(InvestActivity.class).finish();
        }
        finish();
    }

    /**
     * 充值页面
     */
    @JavascriptInterface
    public void gotoHomepage() {
        if (BaseAppManager.getInstance().getActivity(InvestDetailsActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(InvestDetailsActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(MineAssetsActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(MineAssetsActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(MineBankCardActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(MineBankCardActivity.class).finish();
        }

        if (BaseAppManager.getInstance().getActivity(MineSettingActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(MineSettingActivity.class).finish();
        }

        if (!TextUtils.equals(sharedPreferences.getShareProf(UserInfo.IF_ACCOUNT), "YES")) {
            new HSToast(mContext).showToast(mContext.getString(R.string.tips_openaccount));
        } else {
            readyGo(RechangeNewActivity.class);
        }
        finish();
        Log.e("dddd", "name1");
    }

    @JavascriptInterface
    public void withdraw() {
        finish();
    }

    //实名认证结束
    @JavascriptInterface
    public void toPayment() {
        readyGo(ManagementActivity.class);
    }

    @JavascriptInterface
    public void toRepayment() {
        readyGo(ManagementActivity.class);
    }

    @JavascriptInterface
    public void toLend() {
        if (BaseAppManager.getInstance().getActivity(InvestDetailsActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(InvestDetailsActivity.class).finish();
        }
        if (BaseAppManager.getInstance().getActivity(InvestActivity.class) != null) {
            BaseAppManager.getInstance().getActivity(InvestActivity.class).finish();
        }
        readyGo(MineInvestActivity.class);
        finish();
    }
}
